﻿using Kw.Combinatorics;
using System;
using System.Linq;

namespace Kw.CombinatoricsExamples
{
    class McExample05
    {
        static void Main ()
        {
            int n = 9,
                k = 7;
            long rank = 5973;

            // Create a pick-multicombination:

            var mc = new Multicombination (n, k, rank);

            // Access elements using the default enumerator:

            var text = String.Concat (mc.Select (ei => (char) ('A' + ei)));
            Console.WriteLine (text + "\n");

            // Access elements using the indexer:

            for (int i = 0; i < mc.Picks; ++i)
                Console.WriteLine ("Element at {0} is {1}", i, mc[i]);
        }

        /* Output:

        DEFFFHI

        Element at 0 is 3
        Element at 1 is 4
        Element at 2 is 5
        Element at 3 is 5
        Element at 4 is 5
        Element at 5 is 7
        Element at 6 is 8

        */
    }
}
